﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ServiceModel;

namespace WinFormClient
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            CalculatorService.CalculatorClient calculator = new WinFormClient.CalculatorService.CalculatorClient("Calculator");

            double result = calculator.Add(Int32.Parse(textBox1.Text), Int32.Parse(textBox2.Text));

            label2.Text = result.ToString();

            //CalculatorService.CalculatorClient basic = new WinFormClient.CalculatorService.CalculatorClient("basic");

            //MessageBox.Show((basic.Add(Int32.Parse(textBox1.Text), Int32.Parse(textBox2.Text))).ToString());

            using (ChannelFactory<WcfEvalService.ICalculator> channelFactory = new ChannelFactory<WcfEvalService.ICalculator>("basic"))
            {
                WcfEvalService.ICalculator proxy = channelFactory.CreateChannel();
                using (proxy as IDisposable)
                {
                    MessageBox.Show( proxy.Add(3, 7).ToString());
                }
            }
        }
    }
}
